<template>
    <div class="page">
        <div class="page-line">
            <!-- <div class="cell-title">已购模板</div> -->
            <RadioButtonGroupM line v-model="tabActive" :list="tabList" />
            <!-- <AdminSearchGroupM @search="onSearch" /> -->
        </div>

        <div class="buy-list" v-if="filterList.length">
            <div class="buy-item" v-for="item in renderList" :key="item.id">
                <div class="buy-item__image">
                    <img
                        :src="
                            item.info
                                ? item.info.file +
                                  '?x-oss-process=image/watermark,image_' +
                                  toBase64(
                                      'water/logo_white.png?x-oss-process=image/resize,P_30'
                                  ) +
                                  ',g_center,t_60'
                                : ''
                        "
                    />
                </div>

                <div class="buy-item__info">
                    <div class="buy-item__title">
                        {{ item.info ? item.info.name : "-" }}
                    </div>
                    <div class="buy-item__main">
                        <div class="buy-item__id">
                            ID：{{ item.info ? item.info.id : "-" }}
                        </div>
                        <div class="buy-item__createtime">
                            创建时间：{{
                                item.info ? item.info.createtime : "-"
                            }}
                        </div>
                    </div>
                    <div class="buy-item__footer">
                        <div
                            class="buy-item__endtime"
                            v-if="tabActive.vlaue == 1"
                        >
                            过期时间：{{ item.validityendtime }}
                        </div>

                        <div class="edit-btn" @click="onEdit(item)">
                            {{
                                {
                                    1: "编辑",
                                    2: "开始学习",
                                }[tabActive]
                            }}
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <el-empty :image-size="150" v-else />
    </div>
</template>
<script setup>
import { useContent } from ".";

const { tabActive, tabList, filterList, renderList, GetList, onEdit } =
    useContent();

onMounted(() => {
    GetList();
});
</script>
<style lang="scss" scoped>
.page-line {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 15px;
    margin-bottom: 15px;
}

.cell-title {
    position: relative;
    color: #5085fb;
    font-size: 14px;
    padding-left: 8px;
    font-weight: 500;

    &::before {
        content: "";
        position: absolute;
        top: 50%;
        left: 0;
        width: 3px;
        height: 13px;
        border-radius: 20px;
        background-color: #5085fb;
        transform: translateY(-50%);
    }
}

.page {
    padding-bottom: 15px;

    .buy-list {
        padding: 0 15px;

        .buy-item {
            width: 345px;
            padding: 5px;
            background-color: #fff;
            border-radius: 3px;
            overflow: hidden;
            margin-bottom: 15px;

            &:last-of-type {
                margin-bottom: 0;
            }

            &__image {
                width: 100%;
                height: 125px;
                border-radius: 3px;
                overflow: hidden;

                img {
                    width: 100%;
                    height: 100%;
                    object-fit: cover;
                }
            }

            &__info {
                padding: 8px 8px 12px 5px;
            }

            &__id {
                margin-right: 18px;
            }

            &__title {
                font-size: 16px;
                font-weight: 600;
                color: #333;
            }

            &__main,
            &__footer {
                display: flex;
                align-items: center;
                font-size: 13px;
                color: #999;
            }

            &__main {
                margin-top: 22px;
            }

            &__footer {
                margin-top: 12px;

                .edit-btn {
                    display: inline-flex;
                    align-items: center;
                    justify-content: center;
                    height: 30px;
                    background-color: #5185fb;
                    color: #ffffff;
                    font-size: 15px;
                    border-radius: 2px;
                    margin-left: auto;
                    padding: 0 10px;
                }
            }
        }
    }
}
</style>
